//
//  YMBarButtonItem.swift
//  YMWeiBo
//
//  Created by mimi on 16/7/19.
//  Copyright © 2016年 mimi. All rights reserved.
//

import UIKit

class YMBarButtonItem: UIBarButtonItem {
    
 init(title:String? = nil ,imgName:String? = nil,targe:AnyObject ,action:Selector) {
        super.init()
        
        let bt:UIButton = UIButton()
        
        if let tit = title {
            bt.setTitle(tit, forState: .Normal)
            bt.titleLabel?.font = UIFont.systemFontOfSize(15)
            bt.setTitleColor(UIColor.orangeColor(), forState: .Normal)
            bt.setTitleColor(UIColor.darkGrayColor(), forState: .Disabled)
            
            
        }
        
        if let img = imgName {
            
            bt.setImage(UIImage(named: img), forState: .Normal)
            
        }
        
        bt.addTarget(targe, action: action, forControlEvents: .TouchUpInside)
        bt.sizeToFit()
        self.customView = bt
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

}
